From 57c9f2caf05de41913b3e4eb48c0c3ad6c18dd3f Mon Sep 17 00:00:00 2001 From: Jan Beulich Date: Tue, 11 Feb 2014 11:11:48 +0100 Subject: [PATCH] flask: fix memory leaks Plus, in the case of security_preserve_bools(), prevent double freeing in the case of security_get_bools() failing. Signed-off-by: Jan Beulich Reviewed-by: Andrew Cooper Acked-by: Daniel De Graaf --- xen/xsm/flask/flask_op.c | 1 + xen/xsm/flask/ss/services.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/xen/xsm/flask/flask_op.c b/xen/xsm/flask/flask_op.c index 4b93e71e77..e4b07eb04e 100644 --- a/xen/xsm/flask/flask_op.c +++ b/xen/xsm/flask/flask_op.c @@ -347,6 +347,7 @@ static int flask_security_set_bool(struct xen_flask_boolean *arg) if ( arg->bool_id >= num ) { + xfree(values); rv = -ENOENT; goto out; } diff --git a/xen/xsm/flask/ss/services.c b/xen/xsm/flask/ss/services.c index 5cb9537be1..60673175b7 100644 --- a/xen/xsm/flask/ss/services.c +++ b/xen/xsm/flask/ss/services.c @@ -1902,6 +1902,7 @@ err: { for ( i = 0; i < *len; i++ ) xfree((*names)[i]); + xfree(*names); } xfree(*values); goto out; @@ -2011,7 +2012,7 @@ static int security_preserve_bools(struct policydb *p) rc = security_get_bools(&nbools, &bnames, &bvalues, NULL); if ( rc ) - goto out; + return rc; for ( i = 0; i < nbools; i++ ) { booldatum = hashtab_search(p->p_bools.table, bnames[i]); -- 2.30.2